﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using TTSIDAL;
using TTSModel;

namespace TTSDAL
{
    public class T0001996Detail : BaseRepository<T0001996DetailInfo>, IT0001996Detail
    {
         #region 静态变量定义
        private const string PARM_UNITTYPE_ID = "@ID";
        private const string PARM_UNITTYPE_TCODE = "@Tcode";
        private const string PARM_UNITTYPE_TCODENAME = "@TestName";
        private const string PARM_UNITTYPE_TCODEVERSION = "@MeasurementName";
        #endregion

        #region 数据检索部分
        public IList<T0001996DetailInfo> LoadEntities()
        {
            return null;
        }
        public IList<T0001996DetailInfo> LoadEntities(int ID)
        {
            SqlParameter parm = new SqlParameter(PARM_UNITTYPE_ID, SqlDbType.Int, 32);
            parm.Value = ID;
            return ExcuteSqlToGetEntities("T0001996DetailInfo_selectbyID", parm);
        }

        public T0001996DetailInfo LoadEntity<T1>(T1 id)
        {
            SqlParameter parm = GetParameter();
            parm.Value = id;
            return null;
        }

        public T0001996DetailInfo UnitType_GetbyTcode(string tcode)
        {
            SqlParameter parm = new SqlParameter(PARM_UNITTYPE_TCODE, SqlDbType.NChar, 8);
            parm.Value = tcode;
            return null;
        }
        #endregion

        #region 重写基类方法
        public override T0001996DetailInfo GetEntityRecord(SqlDataReader rdr)
        {
            T0001996DetailInfo entity = new T0001996DetailInfo()
            { 
                ID=rdr.GetInt32(0),
               SN = rdr.GetValue(1).ToString(),
               TestName = rdr.GetValue(2).ToString(),
               MeasurementName = rdr.GetValue(3).ToString(),
               Measurement = rdr.GetValue(4).ToString(),
               Unit= rdr.GetValue(5).ToString(),
               LowerLimit = rdr.GetValue(6).ToString(),
               Comparator= rdr.GetValue(7).ToString(),
               UpperLimit = rdr.GetValue(8).ToString(),
               Status = rdr.GetValue(9).ToString(),
               TestDuration = rdr.GetValue(10).ToString(),
               EndTime = rdr.GetValue(11).ToString()       
            };
            return entity;
        }

        public override T0001996DetailInfo GetEntityRecord()
        {
            T0001996DetailInfo entity = new T0001996DetailInfo();
            return null;
        }

        public override string GetInsertsp()
        {
            return null;
        }

        public override string GetUpdatesp()
        {
            return null;
        }

        public override string GetDeletesp()
        {
            return null ;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter parm = new SqlParameter(PARM_UNITTYPE_ID, SqlDbType.NVarChar, 50);
            return parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter(PARM_UNITTYPE_ID,SqlDbType.Int,4),
                new SqlParameter(PARM_UNITTYPE_TCODE,SqlDbType.Text,16),
                new SqlParameter(PARM_UNITTYPE_TCODENAME,SqlDbType.Text,16),
                new SqlParameter(PARM_UNITTYPE_TCODEVERSION,SqlDbType.Text,16),
            };
            return parms;
        }

        public override void SetParameters(T0001996DetailInfo Entity, params SqlParameter[] Parms)
        {
            Parms[0].Value = Entity.SN;
            Parms[1].Value = Entity.TestName;
            Parms[2].Value = Entity.MeasurementName;
            Parms[3].Value = Entity.Measurement;
        }
        #endregion
    
    }
}
